package edu.egypt.sharedpreferences;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class SharedPreferencesSampleActivity extends Activity implements OnClickListener {
    private Button saveButton;
	private Button loadButton;
	private Button emptyButton;
	private EditText editText;

	//objective 1: multiple buttons with the same onClickListener
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        intializeUI();
    }

	private void intializeUI() {
		saveButton = (Button)findViewById(R.id.save_button);
		loadButton = (Button)findViewById(R.id.load_button);
		emptyButton = (Button)findViewById(R.id.empty_button);
		editText = (EditText)findViewById(R.id.editText1);
		
		saveButton.setOnClickListener(this);
		loadButton.setOnClickListener(this);
		emptyButton.setOnClickListener(this);
		
		
	}

	@Override
	public void onClick(View v) {
		if(v.equals(saveButton)){
			editText.setText("save");
		}else if(v.equals(loadButton)){
			editText.setText("load");
		}else{
			editText.setText("");
		}
		
	}
}